// import Cookies from 'js-cookie'

// const TokenKey = 'baoxian_admin_token'

// export function getToken() {
//   return Cookies.get(TokenKey)
// }

// export function setToken(token) {
//   return Cookies.set(TokenKey, token)
// }

// export function removeToken() {
//   return Cookies.remove(TokenKey)
// }

// 缓存
export function getToken() {
  return localStorage.getItem('Token')
}

export function setToken(token) {
  // console.log(token);
  // console.log(localStorage.getItem('token'));
  return localStorage.setItem('Token',token);
}

export function removeToken() {
  return localStorage.removeItem('Token')
}
export function getCookie(name) {
  const value = `; ${document.cookie}`;
  const parts = value.split(`; ${name}=`);
  if (parts.length === 2) return parts.pop().split(';').shift();
}

export function checkLoginStatus() {
  const sessionId = getCookie('PHPSESSID');
  if (sessionId) {
    return true;
  } else {
    return false;
  }
}
// 移除session
export function removeSession() {
  const sessionId = getCookie('PHPSESSID');
  if (sessionId) {
    document.cookie = `PHPSESSID=${sessionId};expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;`;
  }
}